-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements createrawtransaction RPC method #9017
base: main
Are you sure you want to change the base?
Implements createrawtransaction RPC method #9017
Conversation
…Tests to be added in follow-up commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks!
I left some first view comments but i will stop there for now as i think you are still working here.
I think it is important to have snapshot tests here and it will be good to manually compare results with zcashd (we have a tool to help with that).
@@ -77,6 +77,10 @@ impl Height { | |||
/// height and above. | |||
pub const MAX_EXPIRY_HEIGHT: Height = Height(499_999_999); | |||
|
|||
/// The number of blocks within expiry height when a tx is considered | |||
/// to be expiring soon . | |||
pub const BLOCK_EXPIRY_HEIGHT_THRESHOLD: u32 = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a link to zcashd where this constant is defined and used ? I want to make sure they are using the same number.
@@ -3,6 +3,8 @@ | |||
/// Supported opcodes | |||
/// | |||
/// <https://github.com/zcash/zcash/blob/8b16094f6672d8268ff25b2d7bddd6a6207873f7/src/script/script.h#L39> | |||
#[allow(missing_docs)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just add 1 line docs here instead?
/// Returns the hex string of the raw transaction based on the given inputs `transactions`, `addresses`, | ||
/// `locktime` and `expiryheight`. | ||
/// | ||
/// zcashd reference: [`z_create_raw_transaction`](https://zcash.github.io/rpc/createrawtransaction.html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// zcashd reference: [`z_create_raw_transaction`](https://zcash.github.io/rpc/createrawtransaction.html) | |
/// zcashd reference: [`createrawtransaction`](https://zcash.github.io/rpc/createrawtransaction.html) |
/// - `addresses`: (string, required) A json object object with addresses as keys and amounts as values. | ||
/// ["address": x.xxx] (numeric, required) They key is the Zcash address, the value is the ZEC amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check how other addresses fields are documented for Zebra, for example https://github.com/ZcashFoundation/zebra/blob/main/zebra-rpc/src/methods.rs#L100-L101
/// - `expiryheight`: (numeric, optional, default=nextblockheight+20 (pre-Blossom) or nextblockheight+40 (post-Blossom)) Expiry height of | ||
/// transaction (if Overwinter is active) | ||
/// | ||
/// # Notes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// # Notes | |
/// # Notes | |
/// |
let tip_height = best_chain_tip_height(&latest_chain_tip).map_server_error()?; | ||
|
||
let lock_time = if let Some(lock_time) = locktime { | ||
LockTime::Height(block::Height(lock_time)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you intend to get the locktime of the tip here instead ?
)); | ||
} | ||
|
||
// DoS mitigation: reject transactions expiring soon (as is done in zcashd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a reference link
} | ||
|
||
let tx = match current_upgrade { | ||
NetworkUpgrade::Genesis | NetworkUpgrade::BeforeOverwinter => Transaction::V1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unsure if we need to support creating transactions that are below V4.
Implements createrawtransaction RPC method and parameter validation. Tests to be added in follow-up commit.
Motivation
The goal of this PR is to implement the create_raw_transaction RPC endpoint for zebrad. This will support the effort to fully deprecate zcashd and enhance zcashd with all existing zcashd functionality. This PR will close the following issue: #8952
Specifications & References
Solution
Tests
Follow-up Work
PR Author's Checklist
PR Reviewer's Checklist